Laravel remove public from url

Laravel remove public from url

There is two way to remove public from URL in laravel.
  • Step 1
  • Create .htaccess file in root folder and update content
    
    Options -MultiViews -Indexes
        RewriteEngine On
        order allow,deny
        deny from all
       
        order allow,deny
        deny from all
       
        order allow,deny
        deny from all
        
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        RewriteRule ^ %1 [L,R=301]
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    
OR
  • Step 1
  • In your project folder go to public folder . in this folder you are getting  .htaccess file . move this file to your project root folder 
  • Step 2
  • In your project root folder  you are getting server.php file. change this file name index.php 

  • Step 3
  • In your project root folder you are getting .env file . in this file update or add new param
      APP_URL=https://www.yourwebsitename.com/
      ASSET_URL=https://www.yourwebsitename.com/public
    Now  remove public from your url and run your website  then your project will be open without public.

Tags

We are Recommending you:

Leave a comment

Comments